package com.itcast.demo.excelToJson.controller;

import com.itcast.demo.excelToJson.utils.ExcelToJsonConverter;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
public class ExcelController {

    @PostMapping("/convert")
    public String convertExcelToJson(@RequestParam("file") MultipartFile file) {
        try {
            return ExcelToJsonConverter.convert(file);
        } catch (IOException e) {
            return "Conversion failed: " + e.getMessage();
        }
    }
}